package com.room.search.domain.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.room.search.domain.RoomUser;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.util.Assert;

import java.io.Serializable;
import java.util.*;

/**
 * 登录用户身份权限
 *
 * @author bright
 */
public class LoginUser implements Serializable {

    private static final long serialVersionUID = 1L;


    /**
     * username
     */
    private String username;

    /**
     * password
     */
    private String password;

    private Set<GrantedAuthority> authorities;

    /**
     * 用户唯一标识
     */
    private String token;

    /**
     * 登录时间
     */
    private Date loginTime;

    /**
     * 过期时间
     */
    private Date expireTime;

    /**
     * 登录IP地址
     */
    private String ipaddr;

    /**
     * 登录地点
     */
    private String loginLocation;

    /**
     * 浏览器类型
     */
    private String browser;

    /**
     * 操作系统
     */
    private String os;

    /**
     * 权限列表
     */
    private Set<String> permissions;

    /**
     * 用户信息
     */
    private RoomUser roomUser;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getUsername() {
        return username;
    }

    public LoginUser setUsername(String username) {
        this.username = username;
        return this;
    }

    public String getPassword() {
        return password;
    }

    public LoginUser setPassword(String password) {
        this.password = password;
        return this;
    }

    public Set<GrantedAuthority> getAuthorities() {
        return authorities;
    }

    public LoginUser setAuthorities(Set<GrantedAuthority> authorities) {
        this.authorities = authorities;
        return this;
    }

    public String getToken() {
        return token;
    }

    public LoginUser setToken(String token) {
        this.token = token;
        return this;
    }

    public Date getLoginTime() {
        return loginTime;
    }

    public LoginUser setLoginTime(Date loginTime) {
        this.loginTime = loginTime;
        return this;
    }

    public Date getExpireTime() {
        return expireTime;
    }

    public LoginUser setExpireTime(Date expireTime) {
        this.expireTime = expireTime;
        return this;
    }

    public String getIpaddr() {
        return ipaddr;
    }

    public LoginUser setIpaddr(String ipaddr) {
        this.ipaddr = ipaddr;
        return this;
    }

    public String getLoginLocation() {
        return loginLocation;
    }

    public LoginUser setLoginLocation(String loginLocation) {
        this.loginLocation = loginLocation;
        return this;
    }

    public String getBrowser() {
        return browser;
    }

    public LoginUser setBrowser(String browser) {
        this.browser = browser;
        return this;
    }

    public String getOs() {
        return os;
    }

    public LoginUser setOs(String os) {
        this.os = os;
        return this;
    }

    public Set<String> getPermissions() {
        return permissions;
    }

    public LoginUser setPermissions(Set<String> permissions) {
        this.permissions = permissions;
        return this;
    }

    public RoomUser getRoomUser() {
        return roomUser;
    }

    public LoginUser setRoomUser(RoomUser roomUser) {
        this.roomUser = roomUser;
        return this;
    }

    @Override
    public String toString() {
        return "LoginUser{" +
            "username='" + username + '\'' +
            ", password='" + password + '\'' +
            ", authorities=" + authorities +
            ", token='" + token + '\'' +
            ", loginTime=" + loginTime +
            ", expireTime=" + expireTime +
            ", ipaddr='" + ipaddr + '\'' +
            ", loginLocation='" + loginLocation + '\'' +
            ", browser='" + browser + '\'' +
            ", os='" + os + '\'' +
            ", permissions=" + permissions +
            ", roomUser=" + roomUser +
            '}';
    }
}
